home *** CD-ROM | disk | FTP | other *** search
- class §#27§
- {
- static var §#3§ = false;
- function §#27§(context)
- {
- this["#34"] = false;
- this["#192"] = 1;
- this["#17"] = new Sound(context);
- }
- function §#2§()
- {
- return "SoundWrapper (" + this.name + "): ";
- }
- function loadSound(§#288§, name, volume, offset, §#120§)
- {
- this.name = name;
- if(volume == undefined)
- {
- volume = 100;
- }
- this["#28"] = volume;
- this["#22"] = volume;
- this["#17"]["#43"] = this;
- this["#17"].onLoad = function(success)
- {
- if(success)
- {
- this["#43"].setVolume(this["#43"]["#28"]);
- if(offset != undefined)
- {
- this["#43"].start(offset,eval("#120"));
- }
- this["#43"].onLoad();
- }
- else
- {
- eval("#0").log("failed to load " + this["#43"]);
- }
- };
- this["#17"].onSoundComplete = function()
- {
- if(eval("#27")["#3"])
- {
- eval("#0").log(this["#43"] + " complete");
- }
- this["#43"]["#34"] = false;
- this["#43"].onSoundComplete();
- };
- this["#17"].loadSound(§#288§ + "/" + name,false);
- }
- function attachSound(name, volume, offset, §#120§)
- {
- this.name = name;
- this["#17"].attachSound(name);
- if(volume == undefined)
- {
- volume = 100;
- }
- this["#28"] = volume;
- this["#22"] = volume;
- this["#17"].setVolume(volume);
- if(offset != undefined)
- {
- this["#17"].start(offset,§#120§);
- }
- this["#17"]["#43"] = this;
- this["#17"].onSoundComplete = function()
- {
- if(eval("#27")["#3"])
- {
- eval("#0").log(this["#43"] + " complete");
- }
- this["#43"]["#34"] = false;
- this["#43"].onSoundComplete();
- };
- if(eval("#27")["#3"])
- {
- eval("#0").log(this["#2"]() + "attached " + this.toString());
- }
- }
- function start(offset, §#120§)
- {
- if(eval("#27")["#3"])
- {
- eval("#0").log(this["#2"]() + "starting " + this.toString() + ", " + §#120§ + " loops");
- }
- this["#34"] = true;
- this["#17"].start(offset,§#120§);
- if(this["#22"] != this["#28"])
- {
- this["#131"] = _global.setInterval(this,"#167",100);
- }
- }
- function stop()
- {
- if(eval("#27")["#3"])
- {
- eval("#0").log(this["#2"]() + "stopping " + this.toString());
- }
- this["#34"] = false;
- this["#17"].stop();
- }
- function getVolume()
- {
- return this["#28"];
- }
- function setVolume(volume)
- {
- if(eval("#27")["#3"])
- {
- eval("#0").log(this["#2"]() + "setting volume to " + volume);
- }
- this["#28"] = volume;
- this["#22"] = volume;
- this["#17"].setVolume(volume);
- }
- function §#64§(§#28§, time, §#228§)
- {
- if(§#28§ < 0)
- {
- eval("#0").log(this["#2"]() + "bad fade target " + §#28§ + ", setting to 0");
- §#28§ = 0;
- }
- else if(§#28§ > 100)
- {
- eval("#0").log(this["#2"]() + "bad fade target " + §#28§ + ", setting to 100");
- §#28§ = 100;
- }
- if(eval("#27")["#3"])
- {
- eval("#0").log(this["#2"]() + "fading " + this.toString() + "\'s volume to " + §#28§ + " over " + time + "#476");
- }
- this["#22"] = this["#17"].getVolume();
- this["#28"] = §#28§;
- var _loc3_ = §#28§ - this["#22"];
- this["#192"] = Math.abs(_loc3_ / time * 250);
- if(!this["#34"])
- {
- this["#34"] = true;
- this["#17"].start();
- }
- this["#228"] = §#228§;
- clearInterval(this["#131"]);
- this["#131"] = setInterval(this,"#167",250);
- this["#167"]();
- }
- function §#167§()
- {
- if(!this["#34"])
- {
- clearInterval(this["#131"]);
- }
- if(this["#22"] < this["#28"])
- {
- this["#22"] += this["#192"];
- if(this["#22"] > this["#28"])
- {
- this["#22"] = this["#28"];
- }
- }
- else
- {
- this["#22"] -= this["#192"];
- if(this["#22"] < this["#28"])
- {
- this["#22"] = this["#28"];
- }
- }
- if(eval("#27")["#3"])
- {
- eval("#0").log(this["#2"]() + "targetVolume = " + this["#28"] + ", fadeVolume = " + this["#22"]);
- }
- this["#17"].setVolume(this["#22"]);
- if(this["#22"] == this["#28"])
- {
- clearInterval(this["#131"]);
- if(this["#228"])
- {
- this.stop();
- }
- }
- }
- function toString()
- {
- var _loc2_ = "[SoundWrapper name: \"" + this.name + "\"" + ", volume: " + this["#17"].getVolume() + "/" + this["#28"] + ", pan: " + this["#17"].getPan() + ", duration: " + this["#17"].duration + ", position: " + this["#17"].position;
- if(this["#17"].getBytesLoaded() != undefined)
- {
- _loc2_ += ", bytes: " + this["#17"].getBytesLoaded() + "/" + this["#17"].getBytesTotal();
- }
- _loc2_ += "]";
- return _loc2_;
- }
- }
-